package com.dayu.finecomm.dsc.net;

import com.dayu.finecomm.dsc.DSCInterface;

import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;

/**
 * 监听Socket类型基类
 * @author hddz
 * @since 2017-07-26 15:57:30
 * @version V1.0
 */
public class DSCSocketServer {
	
	/**
	 * host name
	 */
	protected String mHost = null;
	
	/**
	 * 绑定端口号
	 */
	protected int mPort = -1;
	
	/**
	 * 消息处理Handle List
	 */
	protected DSCInterface mCallback = null;
	
	/**
	 * 获取回调函数
	 * @return DSCInterface
	 */
	public DSCInterface getCallback() {
		return mCallback;
	}
	
	/**
	 * 启动监听Socket
	 * @return ChannelFuture
	 * @throws InterruptedException
	 */
	public ChannelFuture bootstrap() throws InterruptedException {
		return null;
	}
	
	/**
	 * 退出
	 */
	public void shutdown() {
	}
	
	/**
	 * 发送消息
	 * @param ctx ChannelHandlerContext
	 * @param msg 消息内容
	 * @throws Exception
	 */
	public static void Send(Channel channel, Object msg) throws Exception {
		if (null != channel && null != msg) {
			channel.writeAndFlush(msg);
		}
	}
}
